package org.openFreely.starter;

import org.openFreely.annotation.NettyClient;
import org.openFreely.annotation.NettyServer;
import org.openFreely.utils.ClientUtils;
import org.openFreely.utils.ServerUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.lang.annotation.Annotation;

@NettyServer
@Component
public class Starter implements NettyCommon {
    @Override
    public void bootstrap(){
        Annotation serverAnnotation=getClass().getAnnotation(NettyServer.class);
        if(serverAnnotation!=null){
            ServerUtils.bootstrapServer();
        }
        Annotation clientAnnotation=getClass().getAnnotation(NettyClient.class);
        if(clientAnnotation!=null){
            try {
                ClientUtils.bootstrapClient();
            }catch(InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}
